#! /bin/bash

function tar_file()
{
echo "please imput the director you want to tar:"
read data
if [ -z $data ]
then
echo "error ! please input Diretor/file"
elif [ -d $data ]
then
tar -cvzf $data.tar.gz $data
touch log.txt
echo "backup $data success!" > log.txt
mv log.txt /var/log
echo "$data.tar.gz"
else
echo "erro input"
fi
}

function again()
{
echo "Do you want to tar next file?[0or 1]"
read a
if [ $a -eq 0 ];then
	tar_file
else
	echo "goodbye~"
fi
}
tar_file
again
